# -*- coding: utf-8 -*-
# @Time    : 2022/5/25 10:11
# @Author  : leijiu
# @Email   : 517711635@qq.com
# @File    : goods_brand_list_page.py
# @Software: PyCharm
"""
商品品牌列表页面
"""
from selenium.webdriver.common.by import By
from time import sleep

class GoodsBrandList():
    def __init__(self,driver):
        self.driver=driver

    # 商品品牌定位器
    ele_goodsadmin_locator = (By.CSS_SELECTOR, "#menu-ul > li.collapse.lis.ico_1")
    ele_goodsbrand_locator = (By.LINK_TEXT, "商品品牌")
    ele_addgoodsbrand_locator = (By.LINK_TEXT, "添加品牌")
    # 编辑定位器
    ele_alterbrand_locator = (By.CSS_SELECTOR, "#listDiv > table > tbody > tr:nth-child(2) > td:nth-child(6) > a:nth-child(1)")
    # 删除定位器
    ele_deleterbrand_locator = (By.CSS_SELECTOR, "#listDiv > table > tbody > tr:nth-child(2) > td:nth-child(6) > a:nth-child(2)")
    #断言使用
    # 页面切换
    def leftpage(self):
        self.driver.switch_to.frame("menu-frame")
        sleep(1)
        # 点击商品管理
    def goodsadmin(self):
        self.driver.find_element(*self.ele_goodsadmin_locator).click()
        sleep(1)
    # 点击商品品牌
    def goodsbrand(self):
        self.driver.find_element(*self.ele_goodsbrand_locator).click()
        sleep(1)
        # 切换到主页面
    def mainpage(self):
        self.driver.switch_to.parent_frame()
        self.driver.switch_to.frame("main-frame")
        sleep(1)
    # 点击添加品牌
    def addgoodsbrand(self):
        self.driver.find_element(*self.ele_addgoodsbrand_locator).click()
    # 编辑品牌
    def alterbrand(self):
        self.driver.find_element(*self.ele_alterbrand_locator).click()
    #删除品牌
    def deleterbrand(self):
        self.driver.find_element(*self.ele_deleterbrand_locator).click()
        self.driver.switch_to.alert.accept()
        sleep(1)

